<?php
/* @var $this ProductController */
/* @var $model Product */

$this->breadcrumbs = array(
    'Products' => TreTodayUrl::backendProductUrl(true)
);


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').toggle();
    return false;
});
$('.search-form form').submit(function(){
    $('#product-grid').yiiGridView('update', {
        data: $(this).serialize()
    });
    return false;
});
");
?>
<?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?>
<div class="search-form" style="display:none">
    <?php $this->renderPartial('_search', array(
        'model' => $model,
    )); ?>
</div>
<br/>

<a href="<?php echo TreTodayUrl::backendProductCreateUrl() ?>" class="btn btn-default">Create</a>
<div id="" class="admin-main-wrapper form-inline">
    <div class="dataTables_wrapper">

        <?php $this->widget('zii.widgets.grid.CGridView', array(
            'id' => 'product-grid',
            'dataProvider' => $model->searchForBackendGrid(isset($_GET['published']) && $_GET['published']),
            'filter' => $model,
            'columns' => array(
                'product_id',
                'product_name',
                'user_name',
                array('name' => 'published', 'value' => '$data->published == 1 ? "Có" : "Không"'),
                /*
                'image_id',
                'price',
                'currency',
                'location',
                'buy_method_id',
                'detail',
                'views',
                'add_time',
                'user_id',
                'user_name',
                'modify_time',
                'tieubieu',
                'banchay',
                'published',
                'nick_ym',
                'website',
                'nick_skype',
                'activation_code',
                'status',
                */
                array(
                    'class' => 'CButtonColumn',
                    'template' => '{view}{update}{delete}',
                    'buttons' => array(
                        'view' => array
                        (
                            'label' => 'View',
                            'url' => 'TreTodayUrl::getProductUrl($data->product_id, $data->product_name)',
                            'options' => array("target" => "_blank"),
                        ),

                    )
                ),
            ),
        )); ?>
        <!--        --><?php //$this->widget('zii.widgets.grid.CGridView', array(
        //            'id' => 'product-grid',
        //            'dataProvider'=>$model->search(),
        //            'filter'=>$model,
        //            'columns' => array(
        //                'product_id',
        //                'product_name',
        //                'user_name',
        //                array('name' => 'published', 'value' => '$data->published == 1 ? "Có" : "Không"'),
        //                array(
        //                    'class' => 'CButtonColumn',
        //
        //                ),
        //            ),
        //        ));
        ?>
    </div>
</div>